﻿@{
    ViewBag.Title = "QueJsList2018";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<!--结算列表-->
<form style="margin:2px;margin-top:10px;">
    <div class="gridPanel" style="margin: 5px 10px;">
        <table id="gridList"></table>
    </div>
</form>
<script>
    $(function () {
        var jsdata = sessionStorage.getItem("jsdata");
        var jsondata = JSON.parse(jsdata);
        gridList(jsondata);
    });

    //加载结算列表
    function gridList(mydata) {
        var $gridList = $("#gridList");
        $gridList.newtouchLocalDataGrid({
            height: $(window).height() - 80,
            unwritten: false,
            posttofirst: false,
            colModel: [
                { label: 'jsnm', name: 'jsnm', key: true, hidden: true },
                { label: 'ghly', name: 'ghly', hidden:true},
                {
                    label: '结算类型', name: 'jslx', width: 80, align: "left",
                    formatter: function (val) {
                        return $.enum.getDescByValue("EnumJslx", val);
                    }
                },
                {
                    label: '结算时间', name: 'CreateTime', width: 130, align: "left"
                    , formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' }
                },
                {
                    label: '结算金额', name: 'jszje', width: 80, align: "left",
                    formatter: function (val) {
                        if (val || val == 0) {
                            return val.toFixed(2);
                        } else {
                            return '';
                        }
                    }
                },
                { label: '发票号', name: 'fph', width: 100, align: "left"},
                { label: '收费日期', name: 'sfrq', width: 100, align: "left", formatter: "date", formatoptions: { srcformat: 'Y-m-d', newformat: 'Y-m-d' } },
                { label: '结算人员', name: 'CreatorUserName', width: 80, align: "left" },
            ]
            , ondblClickRow: function (rowid) {
                var frameId = window.name;
                top.$('div#' + frameId + '').siblings('div.layui-layer-btn').find('a.layui-layer-btn0').trigger('click');
            }
        }, mydata);
    }

    function AcceptClick(callBack) {
        var seleRowid = jQuery("#gridList").jqGrid("getGridParam", "selrow");
        if (!(seleRowid)) {
            $.modalAlert("请选中一条信息", 'warning');
            return;
        }
        var rowData = $("#gridList").jqGrid('getRowData', seleRowid);
        if (rowData.jslx == '挂号收费') {
            if (rowData.ghly!='0')
            {
                $.modalAlert('非HIS窗口挂号,不能退费', 'warning');
                return;
            }
            var allData = $("#gridList").jqGrid("getRowData_AllLine");
            for (var i = 0; i < allData.length ; i++) {
                if (allData[i].jsnm != rowData.jsnm
                    && !(allData[i].jslx == '挂号收费')
                    && (!!allData[i].jszje && parseFloat(allData[i].jszje) != 0)) {
                    $.modalAlert('有收费，不能退挂号', 'warning');
                    return;
                }
            }
        }
        if (!(!!rowData.jszje && parseFloat(rowData.jszje) != 0)) {
            $.modalAlert('已无可退金额', 'warning');
            return;
        }
        callBack(rowData.jsnm);
        $.modalClose();
    }

</script>
